

project, uses(../data_output/termlimited.dta)

	use ../data_output/termlimited.dta, clear
	
	keep if state == "CA" | state == "MI"
	
	sort CandId
	by CandId: gen total_years = _N
	drop if terms_in_office > 3
	keep if year >= 1994
	drop if year > 2012
	
	drop if terms_in_office == 3 & total_years == 2
	
	drop if total_years > 3
	
	sum pc1
	replace pc1 = (pc1 - r(mean))/(r(sd))
	
		
	binscatter pc1 terms_in_office, ///
		by(total_years) xq(terms_in_office)  ///
		xlabel(1 2 3, labsize(small)) xtitle("Term in Office", size(small)) ///
		ytitle("Legislator Productivity Index", size(small) height(-8)) linetype(connect) ///
		xscale(range(0.5(1)3.5)) xsize(7) ysize(3) ///
		scale(2) msymbols(D T S) absorb(state) plotregion(margin(zero))  ///
		legend(pos(3) col(1) subtitle("Legislators Who Are...", size(vsmall)) ///
		label(3 "Reelected Twice") label(2 "Reelected Once") ///
		label(1 "Never Reelected") size(vsmall)) savegraph(../tables_figures/three_terms.pdf) replace

	
	
	use ../data_output/termlimited.dta, clear
	keep if permitted_terms == 4
	sort CandId
	by CandId: gen total_years = _N
	drop if terms_in_office > 4
	keep if year >= 1994
	drop if year > 2012
		
	drop if total_years > 4
	drop if terms_in_office > total_years
	
	sum pc1
	replace pc1 = (pc1 - r(mean))/(r(sd))
		
	binscatter pc1 terms_in_office, ///
		by(total_years) xq(terms_in_office)  ///
		xlabel(1 2 3 4, labsize(small)) xtitle("Term in Office", size(small)) ///
		ytitle("", size(small) height(2)) linetype(connect) ///
		xscale(range(0.5(1)4.5)) absorb(state) ///
		scale(2) msymbols(D T S A) xsize(7) ysize(3)   ///
		legend(pos(9) col(1) subtitle("Legislators Who Are...", size(small)) ///
		label(3 "Reelected Twice") label(2 "Reelected Once") ///
		label(1 "Never Reelected") label(4 "Reelected 3x") size(small)) ///
		savegraph(../tables_figures/four_terms.pdf) replace
	
			
